package com.stu.stusystem.common;

import lombok.Getter;
import lombok.Setter;

/**
 * 错误消息返回
 */
public class ApiException extends RuntimeException {
    @Getter
    @Setter
    private Integer code;

    @Getter
    @Setter
    private String message;

    /**
     * 固定错误
     */
    public ApiException(ErrorVM e) {
        this.code = e.getCode();
        this.message = e.getMessage();
    }

    /**
     * 自定义消息错误
     */
    public ApiException(String message) {
        this.code = 500;
        this.message = message;
    }

    public static final String SAVE_FAIL = "保存失败！";
    public static final String DELETE_FAIL = "删除失败！";
    public static final String UPDATE_FAIL = "更新失败！";
    public static final String COUNT_AND_PASSWORD_ERROR = "账号或者密码错误！";
    public static final String COUNT_EXCEPTION = "账户异常！";
    public static final String ERROR_MANY_TIMES = "错误次数过多！";
    public static final String CAN_NOT_FIND = "找不到修改的用户信息！";
    public static final String PASSWORD_ERROR = "您输入的旧密码不正确！";

    public static final ErrorVM BAD_REQUEST = new ErrorVM(400, "请求异常");

    public static final ErrorVM NOT_FOUND = new ErrorVM(404, "404，未找到请求资源");
    public static final ErrorVM UNAUTHORIZED = new ErrorVM(401, "未登录或者登录过期，请重新登录");
    public static final ErrorVM FORBIDDEN = new ErrorVM(403, "没有访问或操作权限");
    public static final ErrorVM REQUEST_VALID_ERROR = new ErrorVM(490, "请求参数验证未通过");

    public static final ErrorVM CREATED = new ErrorVM(201, "Created");
    public static final ErrorVM ACCEPTED = new ErrorVM(202, "Accepted");
    public static final ErrorVM NON_AUTHORITATIVE_INFORMATION = new ErrorVM(203, "Non-Authoritative Information");
    public static final ErrorVM NO_CONTENT = new ErrorVM(204, "No Content");
    public static final ErrorVM RESET_CONTENT = new ErrorVM(205, "Reset Content");
    public static final ErrorVM PARTIAL_CONTENT = new ErrorVM(206, "Partial Content");
    public static final ErrorVM MULTI_STATUS = new ErrorVM(207, "Multi-Status");
    public static final ErrorVM ALREADY_REPORTED = new ErrorVM(208, "Already Reported");
    public static final ErrorVM IM_USED = new ErrorVM(226, "IM Used");
    public static final ErrorVM MULTIPLE_CHOICES = new ErrorVM(300, "Multiple Choices");
    public static final ErrorVM MOVED_PERMANENTLY = new ErrorVM(301, "Moved Permanently");
    public static final ErrorVM FOUND = new ErrorVM(302, "Found");
    public static final ErrorVM SEE_OTHER = new ErrorVM(303, "See Other");
    public static final ErrorVM NOT_MODIFIED = new ErrorVM(304, "Not Modified");
    public static final ErrorVM TEMPORARY_REDIRECT = new ErrorVM(307, "Temporary Redirect");
    public static final ErrorVM PERMANENT_REDIRECT = new ErrorVM(308, "Permanent Redirect");
    public static final ErrorVM PAYMENT_REQUIRED = new ErrorVM(402, "Payment Required");
    public static final ErrorVM METHOD_NOT_ALLOWED = new ErrorVM(405, "Method Not Allowed");
    public static final ErrorVM NOT_ACCEPTABLE = new ErrorVM(406, "Not Acceptable");
    public static final ErrorVM PROXY_AUTHENTICATION_REQUIRED = new ErrorVM(407, "Proxy Authentication Required");
    public static final ErrorVM REQUEST_TIMEOUT = new ErrorVM(408, "Request Timeout");
    public static final ErrorVM CONFLICT = new ErrorVM(409, "Conflict");
    public static final ErrorVM GONE = new ErrorVM(410, "Gone");
    public static final ErrorVM LENGTH_REQUIRED = new ErrorVM(411, "Length Required");
    public static final ErrorVM PRECONDITION_FAILED = new ErrorVM(412, "Precondition Failed");
    public static final ErrorVM PAYLOAD_TOO_LARGE = new ErrorVM(413, "Payload Too Large");
    public static final ErrorVM URI_TOO_LONG = new ErrorVM(414, "URI Too Long");
    public static final ErrorVM UNSUPPORTED_MEDIA_TYPE = new ErrorVM(415, "Unsupported Media Type");
    public static final ErrorVM REQUESTED_RANGE_NOT_SATISFIABLE = new ErrorVM(416, "Requested range not satisfiable");
    public static final ErrorVM EXPECTATION_FAILED = new ErrorVM(417, "Expectation Failed");
    public static final ErrorVM I_AM_A_TEAPOT = new ErrorVM(418, "I'm a teapot");
    public static final ErrorVM UNPROCESSABLE_ENTITY = new ErrorVM(422, "Unprocessable Entity");
    public static final ErrorVM LOCKED = new ErrorVM(423, "Locked");
    public static final ErrorVM FAILED_DEPENDENCY = new ErrorVM(424, "Failed Dependency");
    public static final ErrorVM TOO_EARLY = new ErrorVM(425, "Too Early");
    public static final ErrorVM UPGRADE_REQUIRED = new ErrorVM(426, "Upgrade Required");
    public static final ErrorVM PRECONDITION_REQUIRED = new ErrorVM(428, "Precondition Required");
    public static final ErrorVM TOO_MANY_REQUESTS = new ErrorVM(429, "Too Many Requests");
    public static final ErrorVM REQUEST_HEADER_FIELDS_TOO_LARGE = new ErrorVM(431, "Request Header Fields Too Large");
    public static final ErrorVM UNAVAILABLE_FOR_LEGAL_REASONS = new ErrorVM(451, "Unavailable For Legal Reasons");
    public static final ErrorVM NOT_IMPLEMENTED = new ErrorVM(501, "Not Implemented");
    public static final ErrorVM BAD_GATEWAY = new ErrorVM(502, "Bad Gateway");
    public static final ErrorVM SERVICE_UNAVAILABLE = new ErrorVM(503, "Service Unavailable");
    public static final ErrorVM GATEWAY_TIMEOUT = new ErrorVM(504, "Gateway Timeout");
    public static final ErrorVM HTTP_VERSION_NOT_SUPPORTED = new ErrorVM(505, "HTTP Version not supported");
    public static final ErrorVM VARIANT_ALSO_NEGOTIATES = new ErrorVM(506, "Variant Also Negotiates");
    public static final ErrorVM INSUFFICIENT_STORAGE = new ErrorVM(507, "Insufficient Storage");
    public static final ErrorVM LOOP_DETECTED = new ErrorVM(508, "Loop Detected");
    public static final ErrorVM BANDWIDTH_LIMIT_EXCEEDED = new ErrorVM(509, "Bandwidth Limit Exceeded");
    public static final ErrorVM NOT_EXTENDED = new ErrorVM(510, "Not Extended");
    public static final ErrorVM NETWORK_AUTHENTICATION_REQUIRED = new ErrorVM(511, "Network Authentication Required");
}
